class Solution(object):
    def calculateTime(self, keyboard, word):
        """
        :type keyboard: str
        :type word: str
        :rtype: int
        """
        d = {}
        for i, s in enumerate(keyboard):
            d[s] = i
        value = d[word[0]]
        for i in range(len(word) - 1):
            value += abs(d[word[i + 1]] - d[word[i]])
        return value
